@extends('default.layouts.adminPublic')
@section('title', '合同管理')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/contract_index')}}">首页</a> &raquo; 合同管理
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->

    <div class="con">
        <div class="conMain">
            <div class="result_wrap">
                <div class="search">
                    <form name="Formso" id="Formso" action="{{url('admin/contract_index')}}" method="post">
                        {{csrf_field()}}
                        <span>关键字：</span>
                        <span><input name="keyword" class="keyword" id="keyword" placeholder="请输入公司名称" type="text"></span>
                        <select name="category" id="category" style="width:140px;">
                            <option value="">请选择会员套餐</option>
                            @if(count($vip_package) > 0)
                                @foreach($vip_package as $v )
                                    <option value="{{$v->id}}">{{$v->vipname}}</option>
                                @endforeach
                            @endif
                        </select>
                        <select name="pay" id="pay" style="width:140px;">
                            <option value="">请选择收款方式</option>
                            @if(count($pay) > 0)
                                @foreach($pay as $v )
                                    <option value="{{$v->opt_id}}">{{$v->opt_name}}</option>
                                @endforeach
                            @endif
                        </select>
                        <span><input name="submit" class="skeyword" value="搜索" type="submit"></span>
                    </form>
                </div>
                <div class="message"><p>目前共查找到<strong>{{$company_contract->total()}}</strong>个合同记录！且每页显示合同记录{{$company_contract->perPage()}}个。</p></div>
            </div>
            <div class="manage">
                @include('flash::message')
            </div>
            <div class="conInfo">
                <form name="thisForm" id="thisForm" action="" method="post">
                    {{csrf_field()}}
                    <div class="conList" id="conList">
                        <dl class="one">
                            <dt><input name="selectall" type="checkbox" value="1" onclick="CheckAll(this)" /></dt>
                            <dd class="ph1">公司名称</dd>
                            <dd class="ph2">服务时间</dd>
                            <dd class="ph3">付费方式</dd>
                            <dd class="ph4">会员简历数</dd>
                            <dd class="ph5">会员职位数</dd>
                            <dd class="ph6">会员积分</dd>
                            <dd class="ph7">金额</dd>
                            <dd class="ph8">支付时间</dd>
                            <dd class="ph9">合同操作</dd>
                        </dl>
                        @if($company_contract->count() > 0 )
                            @foreach($company_contract as $v)
                                <dl id="list{{$v->id}}">
                                    <dt><input name="selected_id[]" type="checkbox" value="{{$v->id}}" /></dt>
                                    <dd class="ph1"><a href="{{url('admin/go_com_about?uid='.$v->uid)}}" target="_blank">{{str_limit($v->company_name,28)}}</a></dd>
                                    <dd class="ph2">{{$v->start_time}}~{{$v->end_time}}</dd>
                                    <dd class="ph3">{{$v->pay}}</dd>
                                    <dd class="ph4">{{$v->vip_resume_number}}</dd>
                                    <dd class="ph5">{{$v->vip_post_number}}</dd>
                                    <dd class="ph6">{{$v->vip_integral}}</dd>
                                    <dd class="ph7">{{$v->money}}</dd>
                                    <dd class="ph8">{{$v->pay_time}}</dd>
                                    <dd class="ph9">
                                        <span><a href="{{url('admin/contract/'.$v->id.'/edit')}}">修改合同</a></span>
                                        <span><a onclick="delContract('{{$v->id}}','{{$v->uid}}')">删除合同</a></span>
                                    </dd>
                                </dl>
                            @endforeach
                        @else
                            <div class="nullcon">对不起！没有合同条件的记录！</div>
                        @endif
                        <dl class="last">
                            <dt>
                                <input name="selectall" id="selectall" type="checkbox" value="1" onclick="CheckAll(this)" />
                                <label for="selectall">全选</label>
                            </dt>
                        </dl>
                    </div>
                </form>
                <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                    {!! $company_contract->appends($input)->links() !!}
                </div>
            </div>

            <div class="stopper" style="margin-top:10px; border-top: 1px solid #e5e5e5"></div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script>
        //全选中与全不选中职位资料
        function CheckAll(form){
            if (form.checked==true){
                for (var i=0;i<document.thisForm.elements.length;i++){
                    var e = document.thisForm.elements[i];
                    if (e.name == 'selectedid' || e.name=='selected_id[]' || e.name=='selectall')
                        e.checked=true;
                }
            }else{
                for (var i=0;i<document.thisForm.elements.length;i++){
                    var e = document.thisForm.elements[i];
                    if (e.name == 'selectedid' || e.name=='selected_id[]' || e.name=='selectall')
                        e.checked=false;
                }
            }
        }
        //删除合同
        function delContract(id,uid) {

            layer.open({
                title: '温馨提示',
                area: ['420px','150px'],
                content: '您确定要删除这份合同吗?'
                ,btn: ['删除合同并关闭会员', '删除合同', '取消删除']
                ,yes: function(index, layero){
                    //按钮【按钮一】的回调
                    $.post("/admin/del_contract_close", {'id':id,'uid':uid,'_token': "{{csrf_token()}}"}, function (data) {
                        if (data.status == 0) {
                            layer.msg(data.msg, {icon: 6,time:1500});
                            $("#thisForm").find('#conList').find("#list"+id).remove();
                        } else {
                            layer.msg(data.msg, {icon: 5,time:1500});
                        }
                    });
                }
                ,btn2: function(index, layero){
                    //按钮【按钮二】的回调
                    $.post("{{url('admin/contract/')}}/" + id, {'_method': 'delete','_token': "{{csrf_token()}}"}, function (data) {
                        if (data.status == 0) {
                            layer.msg(data.msg, {icon: 6,time:1500});
                            $("#thisForm").find('#conList').find("#list"+id).remove();
                        } else {
                            layer.msg(data.msg, {icon: 5,time:1500});
                        }
                    });
                }
                ,btn3: function(index, layero){
                }
                ,cancel: function(){
                }
            });
        }
      </script>
@endsection